import { createElementDom } from "./createElementDom"
import { unmountNode } from "./unmountNode"

export function mountNativeElement (vdom, container, oldDom) {

  let newEle = createElementDom(vdom)
  if (oldDom) {
    container.insertBefore(newEle, oldDom)
    oldDom.remove()
  } else {
    container.appendChild(newEle)
  }
  // 旧节点存在，删除
  // oldDom && unmountNode(oldDom)
  // 传递过来的组件实例(类组件才有)
  let component = vdom.component
  component && component.setDom(newEle)
}